#include "PID.h"

float Kp_base=0.7;
float Kd_base=5;


PID motor_pid_l=PID_CREATE(10,1.2,0,1);
PID motor_pid_r=PID_CREATE(0,1.2,0,1);



float PID_Increase(PID*PID,float NowData,float point)
{
	PID->Error=point-NowData;
	PID->Out_P=(PID->Error - PID->LastError);
	PID->Out_I=PID->Error;
	PID->Out_D=(PID->Error-2*PID->LastError+PID->PrevError);
	
	PID->PrevError=0.9*PID->LastError+0.1*PID->PrevError;
	PID->LastError=0.9*PID->Error+0.1*PID->LastError;
	PID->LastData=NowData;
	
	return(PID->Kp*PID->Out_P+PID->Ki*PID->Out_I+PID->Kd*PID->Out_D);

}

